# 3.6 set & setAttr methods
The setAttr(String, Object)
method invokes HttpServletRequest.setAttribute(String, Object)
. This method allows various data to be passed to the View and displayed in the View. By inspecting the JFinal source code of the Controller
, it can be seen that the setAttr(String, Object)
method internally just calls the underlying HttpServletRequest
method:
private HttpServletRequest request;
public Controller setAttr(String name, Object value) {
request.setAttribute(name, value);
return this;
}
1
2
3
4
5
6
2
3
4
5
6
New in JFinal 3.6: To further reduce the amount of code and increase development efficiency, JFinal 3.6 introduced the set
method as a substitute for setAttr
. Here's how to use it:
set("article", article);
// Chaining usage
set("project", project).set("replyList", replyList).render("index.html");
1
2
3
4
2
3
4
JFinal's pursuit of reducing code, enhancing development efficiency, and lowering the learning curve is relentless.